import request from '@/utils/request'

import { GetCurrentUserId } from '@/utils/GetCurrentUserId'
import { Datalist } from './type'
//添加文章
export const Addacrt = (data: any) => request.post('/article/add', data)
//获取文章
export const GetArt = (catagrea: Number, user_id = GetCurrentUserId()) => request.get(`/article/artlist?catagrea=${catagrea}&user_id=${user_id}`)
//删除文章
export const DeleteArt = (id: String) => request.delete(`/article/artlist?id=${id}`)
//在首页获取文章
export const articleHome = (skep: any, catagrea = 0) => request.get<Datalist>(`/article?skep=${skep}&catagrea=${catagrea}`)
//点赞
export const articlelike = (data: any) => request.patch('/article', data)
export const searchdata = (data: any) => request.get(`/search?text=${data}`)

//查询单个文章

export const searchone = (id: string) => request.get(`/search/item?id=${id}`)

export const getlove = (catagrea: Number, id = GetCurrentUserId(),) => request.get(`/artlike?catagrea=${catagrea}&id=${id}`)

export const removelike = (data: Object) => request.patch('/removelike', data)